<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport">
<meta content="yes" name="apple-mobile-web-app-capable">
<meta content="black" name="apple-mobile-web-app-status-bar-style">
<meta content="telephone=no" name="format-detection">
<meta content="email=no" name="format-detection">
<link rel="stylesheet" href="static/index/css/parking.css">
<title>确认缴费</title>
</head>
<body>

<section class="main">
	
	<!-- 确认缴费[[ -->
	<form method="post" action="#" role="form" class="confirm">
	
		<fieldset>

		<div class="info-area">	
			<dl class="totle">
				<dt class="totle-title">停车费</dt>
				<dd class="totle-num"><strong>￥{$orderinfo.pay_money}</strong><!-- 如果打折后金额为0，.totle-discount strong内容修改为：无需缴费 -->
					<a href="#none" class="question-area q-icon"><!-- 图标 --></a><span class="overtime-tips">您未在15分钟内离场，需重新缴费</span>
				</dd>
				
			</dl>

			<ul class="info-list">
				
				<li class="list last-time"><span class="list-title">已停时长</span><span class="list-content">{$orderinfo.in_duration}</span></li>
				<li class="list in-time"><span class="list-title">入场时间</span><span class="list-content">{$orderinfo.in_time}</span></li>
				<li class="list"><span class="list-title">停车卡号</span><span class="list-content">12345678</span></li>
				<li class="list"><span class="list-title">车牌号码</span><span class="list-content">{$orderinfo.car_number}</span></li>
				<li class="list"><span class="list-title">停车位置</span><span class="list-content"><a href=""><span class="map-icon"><!-- 图标 --></span>{$orderinfo.parking_name}</span></a></li>
				<!-- <li class="list over-due"><span class="list-title">已缴费用</span><span class="list-content">￥40</span></li> -->
			</ul>
		</div>
		
		<div class="info-btn">
			<a href="javascript:;" class="btn btn-green" id="pay_btn" onclick="wxorder('{$orderinfo.id}')">立即缴费</a>
			<div class="tips">缴费成功后无需再前往收费处嘀卡</div>
		</div>

		

		</fieldset>
	</form>
	<!-- 确认缴费]] -->

	<div class="wxpay-logo"><!-- 微信支付logo --></div>

</section>

<!-- 重构测试代码，上线前请删除[[ -->
<script type="text/javascript" src="static/index/js/jquery.min.js"></script>
<script type="text/javascript" src="static/index/js/h5_unit_demo.js"></script>
	<script type="text/javascript" src="static/admin/js/jquery-3.2.1.min.js"></script>

<script type="text/javascript">
	function wxorder(id){
				var url = '{:url("index/Order/wxOrderPay")}'
				$.post(url, {id: id}, function(r){
					console.log(r)
					//return
					if (r.jsApiParameters) {
						jsApiCall(r.jsApiParameters)
					}else{
						alert(r.info)
						//location.reload()
					   
					}
				})
			}

			function jsApiCall(jsApiParameters){
				var jsApiParameters = eval('(' + jsApiParameters + ')');
				// console.log(jsApiParameters);
				WeixinJSBridge.invoke(
						'getBrandWCPayRequest',{
						"appId":jsApiParameters['appId'],//公众号名称，由商户传入
						"timeStamp":jsApiParameters['timeStamp'],//时间戳，自1970年以来的秒数
						"nonceStr":jsApiParameters['nonceStr'], //随机串
						"package":jsApiParameters['package'],//预支付交易会话标识
						"signType":jsApiParameters['signType'],//微信签名方式：
						"paySign":jsApiParameters['paySign']//微信签名
					},
					//上面参数一定要按照一定的顺序排列，否则会出错（签名验证失败）
					function(res) {
						//前端接收到支付结果通知，get_brand_wcpay_request:ok，支付成功
						//（但是不一定就是真的成功了，一切以回调地址中的结果为准，前端接收到支付通知后只做跳转，不做任何处理）
						//商户订单处理（更新用户账号余额）要放在回调地址中处理
						if(res.err_msg == "get_brand_wcpay_request:ok" ){
							var id='{$orderinfo.id}';
							 var url = "{:url('index/order/wxok')}?id="+id;
							window.location.href=url;
							
						}
					}
				);
			}
			function delay(){
				if (typeof WeixinJSBridge == "undefined"){
					if( document.addEventListener ){
						document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
					}else if (document.attachEvent){
						document.attachEvent('WeixinJSBridgeReady', onBridgeReady); 
						document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
					}
				}else{
					onBridgeReady();
				}
			}
</script>


</body>
</html>

